SecureSocketBasedObjectRQLProtocol (RoboSuite Java API) 您所在的位置:网站首页 socket api SecureSocketBasedObjectRQLProtocol (RoboSuite Java API)

SecureSocketBasedObjectRQLProtocol (RoboSuite Java API)

2023-04-05 21:18| 来源: 网络整理| 查看: 265

A protocol that sends RQL using a secure socket connection to RoboServer.

The underlying protocol is multiplexing and can't be connected directly to the default port of 50000, it must be connected to the servers SSL port (50043).

Java 1.5 or higher is required to use this protocol commons-ssl-0.3.8.jar or newer must be included in the classpath

This is a multiplexing protocol, which means that for a given host and port, the socket connection will be reused if you create two protocol instances to the same RoboServer. When you are done using the protocol you MUST call close(). If this is that last protocol instance to a RoboServer it will close the socket, you should therefore reuse instance of this protocol, instead of creating new ones.

Correct usage

This (simple) example executes 10 robots using the secure protocol

SecureSocketBasedObjectRQLProtocol protocol = new SecureSocketBasedObjectRQLProtocol("localhost", 50443); try { RQLEngine engine = new RemoteRQLEngine(protocol); RobotExecutor executor = RobotExecutor.getRobotExecutor(engine); for (int i = 0; i < 10; i++) { executor.execute("Library:/helloWorld.robot"); } } finally { // we are done. This closes the socket to RoboServer, and stops internal send/receive threads protocol.close(); } Incorrect Usage

This also executes 10 robot, but because the protocol is closed in each iteration, new sockets and threads are created for every request, greatly reducing performance

for (int i = 0; i < 10; i++) { SecureSocketBasedObjectRQLProtocol protocol = new SecureSocketBasedObjectRQLProtocol("localhost", 50443); try { RQLEngine engine = new RemoteRQLEngine(protocol); RobotExecutor executor = RobotExecutor.getRobotExecutor(engine); executor.execute("Library:/helloWorld.robot"); } finally { protocol.close(); } }

This example shows how to use certificates, for a two-way authentication

String password = "secret"; // The servers public certificate, used to decrypt messages from RoboServer ServerTrustMaterial trust = new ServerTrustMaterial(new File("c:\\certs\\server.pub.cer"), new char[0]); // The clients private certificate (and password) used to encrypt messages to RoboServer ClientCertificate certificate = new ClientCertificate(new File("C:\\certs\\client.p12"), password.toCharArray()); SSLConfiguration sslConfig = new SSLConfiguration(trust, certificate, true, true, true); // create the protocol instance with the selected SSL configuration // the rest is identical regardless of what protocol is used SecureSocketBasedObjectRQLProtocol protocol = new SecureSocketBasedObjectRQLProtocol("localhost", 50043, sslConfig) RQLResult result = null; try { RemoteRQLEngine engine = new RemoteRQLEngine(protocol); result = RobotExecutor.getRobotExecutor(engine).execute("Library:/Test.robot"); } catch (RQLException e) { e.printStackTrace(); } finally { protocol.close(); } System.out.println(result); }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有